import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/store/page/store_product_detail.dart';
import 'package:flutter_douban/model/store_category_model.dart';
import 'package:flutter_douban/tool_views/cached_network_Image.dart';

class StroeSeckillItemCell extends StatefulWidget {
  final StoreCategoryModel model;
  final int index;
  final List<StoreCategoryModel> list;
  const StroeSeckillItemCell(
      {Key? key, required this.model, required this.index, required this.list})
      : super(key: key);

  @override
  _StroeSeckillItemCellState createState() => _StroeSeckillItemCellState();
}

class _StroeSeckillItemCellState extends State<StroeSeckillItemCell> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        margin: EdgeInsets.only(
            left: widget.index == 0 ? 15 : 5,
            right: widget.index == widget.list.length - 1 ? 15 : 5),
        width: 105,
        color: AppColors.page,
        child: Stack(
          children: [
            Column(
              children: [
                ClipRRect(
                  child:
                  CachedImage(url: widget.model.i!, width: 105, height: 105),
                  borderRadius: BorderRadius.circular(8),
                ),
                SizedBox(
                  height: 5,
                ),
                Text(
                  widget.model.n!,
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                    fontSize: 14,
                    color: AppColors.black,
                  ),
                ),
                SizedBox(
                  height: 5,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    Text(
                      "¥" + widget.model.p!,
                      style: TextStyle(
                        fontSize: 14,
                        color: AppColors.danger,
                      ),
                    ),
                    Text(
                      "¥" + widget.model.op!,
                      style: TextStyle(
                        fontSize: 12,
                        color: Colors.black45,
                        decoration: TextDecoration.lineThrough,
                        decorationColor: Colors.black45,
                      ),
                    ),
                  ],
                )
              ],
            ),
            Positioned(
                top: 8,
                left: 8,
                child: Container(
                  height: 18,
                  width: 32,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: AppColors.yellow,
                    border: new Border.all(color: AppColors.yellow, width: 1),
                    borderRadius: BorderRadius.circular(3),
                  ),
                  child: Text(
                    '包邮',
                    style: TextStyle(fontSize: 11, color: AppColors.black),
                  ),
                ))
          ],
        ),
      ),
      onTap: (){
        Navigator.of(context).push(MaterialPageRoute(builder: (_) {
          return StoreProductDetail(model: widget.model,);
        }));
      },
    );
  }
}
